//#include <stdio.h>
////#include <stdlib.h>
////#include "heap.h"
////
////typedef int ElementType;
////typedef struct Node *PtrToNode;
////struct Node {
////    ElementType Data;
////    PtrToNode   Next;
////};
////typedef PtrToNode List;
////
//////带头结点的单链表，其结点存储的数据是递增有序的
////
////List Read(); /* 细节在此不表 */
////void Print( List L ); /* 细节在此不表；空链表将输出NULL */
////
////List Merge( List L1, List L2 );
////
////int main()
////{
////    List L1, L2, L;
////    L1 = Read();
////    L2 = Read();
////    L = Merge(L1, L2);
////    Print(L);
////    Print(L1);
////    Print(L2);
////    return 0;
////}
////
////List Read() {
////    List r,L=(struct Node*)malloc(sizeof(struct Node));
////    L->Next=NULL;//创建一个头节点；一般链表都是带头节点的;头节点的 Data是没有存放数据的 ；当然也可以创建没有头节点的链表；
////    //因为带有头节点的 链表，可以让print操作更加简练；因此链表都是有一个 不存放数据的头节点的；
////    r=L;
////    int n;
////    scanf("%d",&n);
////    while(n--) {///尾插法
////        Node *p=(struct Node*)malloc(sizeof(struct Node));
////        scanf("%d",&p->Data);
////        p->Next=NULL;
////        r->Next=p;
////        r=p;
////    }
////    return L;
////}
////
////
////
////void Print(List L) {
////    if(L->Next) {
////        List r=L;
////        while(r->Next) {
////            r=r->Next;
////            printf("%d ",r->Data);
////        }
////        puts("");
////    } else {
////        printf("NULL\n");
////    }
////}
////
/////* 你的代码将被嵌在这里 */
////List Merge( List L1, List L2 ){
////    if(L1->Next == NULL){
////        return L2;
////    }
////    if(L2->Next == NULL){
////        return L1;
////    }
////    List p=L1->Next;
////    List q=L2->Next;
////    List head =(List)malloc(sizeof(struct Node));
////    head->Next=NULL;
////    List rear=head;
////    while (p != NULL && q != NULL){
////        if(p->Data <= q->Data){
////            List  tmp=p->Next;
////            rear->Next=p;
////            rear=p;
////            p->Next=NULL;
////            p=tmp;
////        } else{
////            List  tmp=q->Next;
////            q->Next=NULL;
////            rear->Next=q;
////            rear=q;
////            q=tmp;
////        }
////    }
////    if(p!=NULL){
////        rear->Next=p;
////    }
////    if(q != NULL){
////        rear->Next=q;
////    }
////    L1->Next=NULL;
////    L2->Next=NULL;
////    return head;
////}

#include <stdio.h>
#include <stdlib.h>

typedef enum { false, true } bool;
typedef int ElementType;
typedef struct TNode *Position;
typedef Position BinTree;
struct TNode{
    ElementType Data;
    BinTree Left;
    BinTree Right;
};

BinTree BuildTree(); /* 由裁判实现，细节不表 */
bool IsBST ( BinTree T );

int main()
{
    BinTree T;

    T = BuildTree();
    if ( IsBST(T) ) printf("Yes\n");
    else printf("No\n");

    return 0;
}
/* 你的代码将被嵌在这里 */

bool IsBST ( BinTree T ){
    //中序遍历为有序序列
    if(T == NULL){
        return true;
    }
    static BinTree pre;
    BinTree  p=T;
    if (!IsBST(p->Right)){
        return false;
    }
    if (pre != NULL && pre->Data < p->Data ){
        return false;
    }
    //暂存之前节点用于判断是否有序
    pre=p;

    if (!IsBST(p->Left)){
        return false;
    }
    return true;
}